part of '../repository.dart';

class _WebTransactionDtoFactory {
  const _WebTransactionDtoFactory._internal();

  static const _instance = _WebTransactionDtoFactory._internal();

  factory _WebTransactionDtoFactory() {
    return _instance;
  }

  _WebTransactionDto fromJson(Map<String, dynamic> json) {
    final paymentSystem = json[_kWebTransactionPaymentSystemKey] as String;

    if (paymentSystem == _kWebTransactionYookassaPaymentSystemValue) {
      return _YookassaTransactionDtoFactory().fromJson(json);
    }

    throw UnimplementedError();
  }

  _WebTransactionDto fromEntity(WebTransaction webTransaction) {
    if (webTransaction is YookassaTransaction) {
      return _YookassaTransactionDtoFactory().fromEntity(webTransaction);
    }

    throw UnimplementedError();
  }
}
